import { defineStore } from "pinia";
import { getLoginApi } from "@/api/user";
import { ref } from "vue";
export const useUserStore = defineStore(
  "user",
  () => {
    const userInfo = ref({});
    const useUserInfo = async (name, password) => {
      const res = await getLoginApi(name, password);
      console.log(res);
      userInfo.value = res.result;
    };
    const clearUserStore = () => {
      userInfo.value = {};
    };
    return {
      userInfo,
      useUserInfo,
      clearUserStore,
    };
  },
  {
    persist: true,
  }
);
